/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"fmt"

	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"github.com/spf13/cobra"
)

// ginserverCmd represents the ginserver command
var ginserverCmd = &cobra.Command{
	Use:   "ginserver",
	Short: "创建 gin 静态页面服务",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		gin.SetMode(gin.DebugMode)

		r := gin.Default()
		r.Use(cors.Default())
		r.StaticFS("/", gin.Dir(".", true))
		r.Run(fmt.Sprintf(":%v", REMOTE_SERVER))
	},
}

func init() {
	rootCmd.AddCommand(ginserverCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// ginserverCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// ginserverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
